package tbs.framework.sql.extractor.impls.mysql;

import tbs.framework.sql.extractor.IGroupSqlExtractor;
import tbs.framework.sql.model.SqlGroupModel;

import java.util.List;

public class MysqlGroupExtractor implements IGroupSqlExtractor {

    @Override
    public String extraGroupBySql(List<SqlGroupModel> sqlGroupModels) {
        StringBuilder sb = new StringBuilder();
        for (SqlGroupModel sqlGroupModel : sqlGroupModels) {
            sb.append(sqlGroupModel.getFieldName());
            sb.append(",");
        }
        return " group by " + sb.substring(0, sb.length() - 1);
    }
}
